import request from "@/utils/request";

// 查询部门列表
export function listType(query) {
  return request({
    url: "/system/module/type/list",
    method: "get",
    params: query,
  });
}

// 查询部门列表（排除节点）
export function listTypeExcludeChild(typeId) {
  return request({
    url: "/system/module/type/list/exclude/" + typeId,
    method: "get",
  });
}

// 查询部门详细
export function getType(typeId) {
  return request({
    url: "/system/module/type/" + typeId,
    method: "get",
  });
}

// 查询部门下拉树结构
export function treeselect() {
  return request({
    url: "/system/module/type/treeselect",
    method: "get",
  });
}

// 查询部门下拉树结构
export function treeselectbyId(typeId) {
  return request({
    url: "/system/module/type/treeselect/",
    method: "get",
  });
}

// 根据角色ID查询部门树结构
export function roleTypeTreeselect(roleId) {
  return request({
    url: "/system/module/type/roleTypeTreeselect/" + roleId,
    method: "get",
  });
}

// 新增部门
export function addType(data) {
  return request({
    url: "/system/module/type",
    method: "post",
    data: data,
  });
}

export function addRootType(data) {
  return request({
    url: "/system/module/type/addRootType",
    method: "post",
    data: data,
  });
}

// 修改部门
export function updateType(data) {
  return request({
    url: "/system/module/type",
    method: "put",
    data: data,
  });
}

// 删除部门
export function delType(typeId) {
  return request({
    url: "/system/module/type/" + typeId,
    method: "delete",
  });
}
